//
// Created by ChenJi on 2021/3/9.
//

#ifndef F407TEST_DEBUG_BUTTON_EXTERN_H
#define F407TEST_DEBUG_BUTTON_EXTERN_H

#endif //F407TEST_DEBUG_BUTTON_EXTERN_H
#include "main.h"



void button_init();

void handleButtons();

struct ButtonHandler {
    uint8_t buttonid;
    uint16_t button_reg;
    uint16_t button_time_limit;
    uint8_t button_long_press_mode;
    uint8_t button_listen_enable;
    uint8_t button_cycle_listen;
    GPIO_PinState button_isPressed;
    GPIO_PinState button_latest_state;
    uint8_t button_start_mode;
    uint8_t button_in_long_press_mode;
    uint8_t button_hold_callback_enable;
    uint8_t button_hold_callback_reg;
    uint8_t button_hold_callback_cycle;

};

void handleButtonTick(struct ButtonHandler *handle);

void initButton(struct ButtonHandler *handle);

void onPressDownCallback(struct ButtonHandler *handle);

void onFreeCallback(struct ButtonHandler *handle);

void onTimeReachCallback(struct ButtonHandler *handle);

void onHoldCycleCallback(struct ButtonHandler *handle);
void buttonRegister(uint8_t buttonid, uint16_t time, uint8_t mode, uint8_t cyclelisten, uint8_t hold_callback);